/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package maxspan;

import java.util.LinkedList;
import java.util.Scanner;

/**
 *
 * @author TQNINH
 */
public class EmployeeList {
    
    LinkedList objLinkedList;

    public EmployeeList() {
        objLinkedList = new LinkedList();
    }
    
    void add() {
        String employeeName = "";
        Scanner input = new Scanner(System.in);
        
        System.out.print("Enter the name of the employee: ");
        employeeName = input.nextLine();
        
        objLinkedList.add(employeeName);
    }
    
    void display() {
        System.out.println("\n**********************************************");
        System.out.println("Retrieve all the employee names from the database");
        System.out.println("**********************************************");
        System.out.println();
        
        for (int ctr = 0; ctr < objLinkedList.size(); ctr++) {
            System.out.print(objLinkedList.get(ctr) + "\n");
        }
    }
    
    void search() {
        String searchName = "";
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the first name of the Employee to search: ");
        searchName = input.nextLine();
        
        System.out.println("**********************************************");
        System.out.println("Searching for required employees from the database");
        System.out.println("**********************************************");
        System.out.println();
        
        for (int ctr = 0; ctr < objLinkedList.size(); ctr++) {
            Object name = objLinkedList.get(ctr);
            
            if(name.toString().startsWith(searchName)) {
                System.out.println(name);
            }
        }
    }
}
